package com.ttdev.mmms.controller.account;

import com.ttdev.mmms.entity.Account;
import com.ttdev.mmms.entity.MemberInfo;
import com.ttdev.mmms.repository.ConsumptionRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @author 杨培朔
 * @create 2019-12-02 20:30
 * 2019-12-5 09:37:54
 * 会员消费记录
 */
@RestController
@RequestMapping("/consumption")
public class AccountController {

    @Autowired
    private ConsumptionRepository consumptionRepository;

    /**
     * 会员查账功能
     * 查询会员的账单
     */
    @GetMapping
    public ModelAndView queryAll(HttpSession session) {
        MemberInfo member=(MemberInfo)session.getAttribute("member");
        int id=member.getCardId();
        List<Account> consumptionList = consumptionRepository.findAll(id);
        ModelAndView model = new ModelAndView();
        model.setViewName("member/expenseCalendar");
        model.addObject("List", consumptionList);
        return model;

    }

}

